import openpyxl
import pytest
from selenium import webdriver
from UI_web_A3mall.config.config import Base

@pytest.fixture
def driver():
    driver = webdriver.Edge()
    yield driver
    driver.quit()

def test_01(driver):
    work = openpyxl.load_workbook(r'E:\gg4\gaoliu\UI_web_A3mall\data\A3mall.xlsx')
    excel = work['Sheet1']
    base = Base(driver)
    for row in excel.iter_rows(min_row=2,values_only=True):
        action = row[2]
        p = {}
        if action == 'open_url':
            p['url'] = row[5]
        elif action in ['click','send_keys','ddddocr']:
            p['loc'] = [row[3],row[4]]
            if action == 'send_keys':
                p['info'] = row[5]
            elif action == 'ddddocr':
                p['loc2'] = [row[6], row[7]]

        method = getattr(base,str(action))
        method(**p)